<?php
function converte_data($data) 
{
     if (strstr($data, "/")) 
     {//verifica se tem a barra /
         $d = explode ("/", $data);//tira a barra
         $rstData = "$d[2]-$d[1]-$d[0]";//separa as datas $d[2] = ano $d[1] = mes etc...
         return $rstData;
     }
     else if(strstr($data, "-")) 
     {
        $data    = substr($data, 0, 10);
        $d       = explode ("-", $data);
        $rstData = "$d[2]/$d[1]/$d[0]";
        return $rstData;
     }
     else
     {
         return '';
    }
}